package com.zzw.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.zzw.utils.*;
import com.zzw.bean.ClassOfStudent;
import com.zzw.bean.Course;
import com.zzw.bean.Curriculum;
import com.zzw.bean.Student;
import com.zzw.bean.User;
import com.zzw.service.imple.IClassOfStudentService;
import com.zzw.service.imple.ICourseService;
import com.zzw.service.imple.ICurriculumService;
import com.zzw.service.imple.IUserService;


@Controller
public class CurriculumController {
	
	@Autowired
	ICurriculumService curriculumService;
	@Autowired
	IClassOfStudentService iClass;
	@Autowired
	ICourseService ic;
	
	/**
	 * 转发页面
	 * */
	@RequestMapping("/curriculumList.do")
	@ResponseBody
	public ModelAndView curriculumList(Curriculum curriculum) {
		ModelAndView mv=new ModelAndView();
		List<Curriculum> list=curriculumService.selectCurriculum(curriculum);
		List<ClassOfStudent> classNameList=iClass.selectClass(null);
		List<Course> courseNameList=ic.selectCourse(null);
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("list", list);
		map.put("classNameList",classNameList);
		map.put("courseNameList",courseNameList);
		mv.addAllObjects(map);
		mv.setViewName("curriculum_list");
		return mv;
	}
	
	/**
	 * 删除用户
	 * */
	@RequestMapping("deleteCurriculum.do")
	@ResponseBody
	public Result deleteCurriculum(Curriculum curriculum) {
		Result result=null;
		curriculumService.deleteCurriculum(curriculum);
		result=ResultUtils.success();
		return result;
	}
	
	
	/**
	 * id查询单个用于用户
	 * */
	@RequestMapping("/selectCurriculumById.do")
	@ResponseBody
	public Result selectCurriculumById(Curriculum curriculum) {
		Result result=null;
		Curriculum curr=curriculumService.selectCurriculumById(curriculum);
		result=ResultUtils.success(curr);
		return result;
	}
	
	/**
	 * 更新单个用于用户
	 * */
	@RequestMapping("/updateCurriculum.do")
	@ResponseBody
	public Result updateCurriculum(Curriculum curriculum) {
		Result result=null;
		curriculumService.updateCurriculum(curriculum);
		result=ResultUtils.success();
		return result;
	}
	

}
